﻿var Position = function(data) {
    this.Id = ko.observable(data.Id ? data.Id : 0);
    this.Created = ko.observable(data.Created ? data.Created : "");
    this.Updated = ko.observable(data.Updated ? data.Updated : "");
    this.Title = ko.observable(data.Title ? data.Title : "").extend({
        required: true,
        maxLength: 50
    });
    this.Description = ko.observable(data.Description ? data.Description : "").extend({
        required: true,
        maxLength: 1024
    });
    this.DescriptionShort = ko.observable(data.Description ? data.Description.length > 40 ? data.Description.substring(0, 100) + "..." : data.Description : "");
    this.StartDate = ko.observable(data.StartDate ? new Date(data.StartDate) : new Date()).extend({
        required: true
    });
    this.Duration = ko.observable(data.Duration ? data.Duration : "").extend({
        required: true
    });
    this.Location = ko.observable(data.Location ? data.Location : "").extend({
        required: true
    });
    this.IsDefault = ko.observable(data.IsDefault ? data.IsDefault : false);
    this.Photo = ko.observable(data.Photo ? data.Photo : "../../Content/img/250X250_home-project-icon.jpg").extend({
        maxLength: 250
    });
    this.Photo150X150 = ko.observable(data.Photo150X150 ? data.Photo150X150 : "../../Content/img/150X150_home-project-icon.jpg").extend({
        maxLength: 250
    });
    this.Photo80X80 = ko.observable(data.Photo80X80 ? data.Photo80X80 : "../../Content/img/80X80_home-project-icon.jpg").extend({
        maxLength: 250
    });
    this.Photo50X50 = ko.observable(data.Photo50X50 ? data.Photo50X50 : "../../Content/img/50X50_home-project-icon.jpg").extend({
        maxLength: 250
    });
    this.JobType = ko.observable(data.JobType ? data.JobType : null).extend({
        required: true
    });
    this.JobTypeText = ko.observable(data.JobTypeText ? data.JobTypeText : "");
    this.Categories = ko.observableArray(data.Categories ? data.Categories : []);
    this.Technologies = ko.observableArray(data.Technologies ? data.Technologies : []);
    this.Company = ko.observable(data.Company ? data.Company : "");
    this.CompanyProfileId = ko.observable(data.CompanyProfileId ? data.CompanyProfileId : 0);
    this.Country = ko.observable(data.Country ? data.Country : null).extend({
        required: true
    }); 
    this.CountryId = ko.observable(data.CountryId ? data.CountryId : 0);
    this.Industry = ko.observable(data.Industry ? data.Industry : null).extend({
        required: true
    });
    this.IndustryId = ko.observable(data.IndustryId ? data.IndustryId : 0);
    this.CountryFlag = ko.observable(data.CountryFlag ? data.CountryFlag : "");
    this.UserId = ko.observable(data.UserId ? data.UserId : 0);
    this.errors = ko.validation.group(this);
    return;
}